<template>
  <div @click="$router.push('/details/' + postData.id)">
    <!-- 单张图片文章 -->
    <div
      class="singleImg"
      v-if="postData.type == 1 && postData.cover.length <= 1"
    >
      <div class="left">
        <div class="title">{{ postData.title }}</div>
        <div class="info">
          {{ postData.user.nickname }} {{ postData.comment_length }}跟帖
        </div>
      </div>
      <img :src="postData.cover[0].url" alt="" />
    </div>
    <!-- 多张图片文章 -->
    <div
      class="multiImg"
      v-if="postData.type == 1 && postData.cover.length >= 3"
    >
      <div class="title">{{ postData.title }}</div>
      <div class="imgList">
        <img :src="postData.cover[0].url" alt="" />
        <img :src="postData.cover[1].url" alt="" />
        <img :src="postData.cover[2].url" alt="" />
      </div>
      <div class="info">
        {{ postData.user.nickname }} {{ postData.comment_length }}跟帖
      </div>
    </div>
    <!-- 视频文章 -->
    <div class="singleVideo" v-if="postData.type == 2">
      <div class="title">{{ postData.title }}</div>
      <div class="wrap">
        <img :src="postData.cover[0].url" alt="" />
        <div class="videoWrap">
          <span class="iconfont iconshipin"></span>
        </div>
      </div>
      <div class="info">
        {{ postData.user.nickname }} {{ postData.comment_length }}跟帖
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["postData"],
};
</script>

<style lang="less" scoped>
.singleImg {
  display: flex;
  justify-content: space-between;
  padding: 12 / 360 * 100vw;
  border-bottom: 1px solid #ccc;
  .left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .title {
      font-size: 16 / 360 * 100vw;
    }
    .info {
      font-size: 14 / 360 * 100vw;
      color: #888;
    }
  }
  img {
    width: 112 / 360 * 100vw;
    height: 74/ 360 * 100vw;
    object-fit: cover;
  }
}
.multiImg {
  padding: 12 / 360 * 100vw;
  border-bottom: 1px solid #ccc;
  .title {
    font-size: 16 / 360 * 100vw;
    margin-bottom: 10 / 360 * 100vw;
  }
  .imgList {
    display: flex;
  }
  img {
    flex: 1;
    width: 33%;
    margin-right: 4 / 360 * 100vw;
    height: 74 / 360 * 100vw;
    object-fit: cover;
  }
  .info {
    font-size: 14 / 360 * 100vw;
    color: #888;
    margin-top: 10 / 360 * 100vw;
  }
}
.singleVideo {
  padding: 12 / 360 * 100vw;
  border-bottom: 1px solid #ccc;
  .title {
    margin-bottom: 10 / 360 * 100vw;
  }
  .wrap {
    width: 100%;
    position: relative;
    img {
      width: 100%;
      height: 170 / 360 * 100vw;
      object-fit: cover;
    }

    .videoWrap {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      span {
        width: 48 / 360 * 100vw;
        height: 48 / 360 * 100vw;
        line-height: 48 / 360 * 100vw;
        font-size: 48 / 360 * 100vw;
        background-color: rgba(0, 0, 0, 0.3);
        border-radius: 50%;
        color: #fff;
      }
    }
  }
  .info {
    font-size: 14 / 360 * 100vw;
    color: #888;
    margin-top: 10 / 360 * 100vw;
  }
}
</style>
